package com.ruoyi.web.controller.game;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.game.domain.GameXinfa;
import com.ruoyi.game.service.IGameXinfaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 心法Controller
 *
 * @author ghostmen
 * @date 2024-10-29
 */
@Api(value = "心法", tags = "心法接口")
@RestController
@RequestMapping("/game/xinfa")
public class GameXinfaController extends BaseController {
    @Autowired
    private IGameXinfaService gameXinfaService;

    /**
     * 查询心法列表
     */
    @ApiOperation("查询心法列表")
    @PreAuthorize("@ss.hasPermi('game:xinfa:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameXinfa gameXinfa) {
        startPage();
        List<GameXinfa> list = gameXinfaService.selectGameXinfaList(gameXinfa);
        return getDataTable(list);
    }


    /**
     * 获取心法详细信息
     */
    @ApiOperation("获取心法详细信息")
    @PreAuthorize("@ss.hasPermi('game:xinfa:query')")
    @GetMapping(value = "/{xinfaId}")
    public AjaxResult getInfo(@PathVariable("xinfaId") Long xinfaId) {
        return success(gameXinfaService.selectGameXinfaByXinfaId(xinfaId));
    }

    /**
     * 新增心法
     */
    @ApiOperation("新增心法")
    @PreAuthorize("@ss.hasPermi('game:xinfa:add')")
    @Log(title = "心法", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameXinfa gameXinfa) {
        return toAjax(gameXinfaService.insertGameXinfa(gameXinfa));
    }

    /**
     * 修改心法
     */
    @ApiOperation("修改心法")
    @PreAuthorize("@ss.hasPermi('game:xinfa:edit')")
    @Log(title = "心法", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameXinfa gameXinfa) {
        return toAjax(gameXinfaService.updateGameXinfa(gameXinfa));
    }

    /**
     * 删除心法
     */
    @ApiOperation("删除心法")
    @PreAuthorize("@ss.hasPermi('game:xinfa:remove')")
    @Log(title = "心法", businessType = BusinessType.DELETE)
    @DeleteMapping("/{xinfaIds}")
    public AjaxResult remove(@PathVariable Long[] xinfaIds) {
        return toAjax(gameXinfaService.deleteByXinfaIds(xinfaIds));
    }
}
